<template>
  <div class="like-page">
        <van-nav-bar title="喜欢列表" fixed/>
        <van-list
        style="margin-bottom: 40px;margin-top: 40px;"
            v-model="loading"
            :finished="finished"
            finished-text="没有更多了"
            @load="onLoad"
        > 
        <ArticleItem v-for="item in list" :key="item.id" :item="item" @click.native="$router.push(`/detall/${item.id}`)"></ArticleItem>
        </van-list>
  </div>
</template>

<script>
//导入接口
import {getLikeList} from '@/api/article'
export default {
    name:'like-page',
    data() {
        return {
            page:1,
            pageSize:5,
            list:[],
            loading:false,
            finished:false
        }
    },
    methods:{
      async onLoad(){
            const data = await getLikeList({
                page:this.page,
                pageSize:this.pageSize
            })
            //添加到数组末尾
            this.list.push(...data.data.rows)
            this.page++
            this.loading=false
            if(data.data.rows.length === 0){
                this.finished = true
            }
        }
    }
}
</script>

<style>
*{
    margin: 0;
    padding: 0;
}
</style>